<%@ include file="/WEB-INF/jsp/header.jsp" %>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 

<h1>${photo.gallery.name}</h1>
<h3>od uživatele: ${photo.gallery.owner.userName}</h3>


<img src="${pageContext.request.contextPath}/uploaded/${photo.gallery.owner.userName}/${photo.gallery.rootFolder}/${photo.fileName}" height="600" />

<form:form modelAttribute="comment" method="POST">
  <table>
    <tr>
      <th>
        Text komentáře: <form:errors path="text" cssClass="errors"/>
        <br/>
        <form:textarea path="text" cols="50" rows="5"/>
      </th>
    </tr>
    
    <tr>
      <td>
      	<p class="submit"><input type="submit" value="Vložit komentář"/></p>
      </td>
    </tr>
  </table>
</form:form>

<h2>Komentáře k fotografii:</h2>
<c:choose>
  	<c:when test="${empty photo.comments}">
  		<p>Tuto fotografii dosud nikdo nekomentoval</p> 
  	</c:when>
  	<c:otherwise>
  		<c:forEach var="comment" items="${photo.comments}">
  			<div class="comment">
				<div class="commentText">
					${comment.text}
				</div>
				<div class="commentHeader">
					vložil: ${comment.author.userName} 
				</div>
			</div>
		</c:forEach>
  	</c:otherwise>
</c:choose>



<%@ include file="/WEB-INF/jsp/footer.jsp" %>